﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using RazorBridge.Mvc;

namespace RazorBridge.Helpers
{
    /// <summary>
    /// Utility class
    /// </summary>
   static class FrameworkUtility
    {
       /// <summary>
       /// Create combined view associated with plugin name
       /// </summary>
       /// <param name="pluginKey">Plugin key for container</param>
       /// <param name="viewKey">View key to get file path</param>
       /// <returns>Return full view path</returns>
       public static string CreateCombinedViewName(string pluginKey, string viewKey)
       {
           return string.Format(CultureInfo.InvariantCulture,"{0}{1}{2}", pluginKey,Constants.PATH_SEPARATOR, viewKey);
       }

       /// <summary>
       /// Split strings in to array
       /// </summary>
       /// <param name="value">value to split</param>
       /// <param name="token">separator char</param>
       /// <returns>Returns array</returns>
       public static string[] SplitString(string value, char token)
       {
           return value.Split(token);
       }

       /// <summary>
       /// Trim assembly name ends with .dll or .exe
       /// </summary>
       /// <param name="assemblyName">assembly name</param>
       /// <returns>Returns qualified assembly name</returns>
       public static string FormatedAssemblyName(string assemblyName)
       {
           if (!string.IsNullOrWhiteSpace(assemblyName) && (assemblyName.EndsWith(Constants.ASSEMBLY_DLL_WILD_CARD, StringComparison.OrdinalIgnoreCase) || assemblyName.EndsWith(Constants.ASSEMBLY_EXE_WILD_CARD, StringComparison.OrdinalIgnoreCase)))
           {
               return assemblyName.Substring(0, assemblyName.Length - 4);
           }
           return assemblyName;
       }
    }
}
